package com.example.user.controller.contest;

import com.example.common.core.constants.HttpConstants;
import com.example.common.core.controller.BaseController;
import com.example.common.core.domain.R;
import com.example.common.core.domain.TableDataInfo;
import com.example.user.aspect.CheckUserStatus;
import com.example.user.domain.contest.dto.ContestDTO;
import com.example.user.domain.contest.dto.ContestQueryDTO;
import com.example.user.service.contest.impl.UserContestServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/contest")
public class UserContestController extends BaseController {
    @Autowired
    private UserContestServiceImpl userContestService;

    @CheckUserStatus
    @PostMapping("/enter")
    public R<Void> enter(@RequestHeader(HttpConstants.AUTHENTICATION) String token, @RequestBody ContestDTO contestDTO) {
        return toR(userContestService.enter(token, contestDTO));
    }

    @GetMapping("/list")
    public TableDataInfo list(ContestQueryDTO contestQueryDTO) {

        return userContestService.list(contestQueryDTO);
    }

}
